import React, { useContext } from 'react'
import myContext from '../usecontext.js'
import { Table } from 'antd';




export default function Memory(props) {
  const seaver = useContext(myContext);

  const { mem, jvm } = seaver
  const columns = [
    {
      title: '属性',
      dataIndex: 'name',
      key: 'name',
    },
    {
      title: '内存',
      dataIndex: 'value',
      key: 'value',
    },
    {
      title: 'JVM',
      dataIndex: 'jvm',
      key: 'value',
    }
  ]
  const data = [
    {
      key: '1',
      name: '总内存',
      value: mem.total + 'G',
      jvm: jvm.total + 'M'
    },
    {
      key: '3',
      name: '已用内存',
      value: mem.used + 'G',
      jvm: jvm.used + 'M'
    },
    {
      key: '4',
      name: '剩余内存',
      value: mem.free + 'G',
      jvm: jvm.free + 'M'
    },
    {
      key: '5',
      name: '使用率',
      value: mem.usage + '%',
      jvm: jvm.usage + '%'
    },
  ]
  return (
    <Table bordered={true} pagination={false} columns={columns} dataSource={data} />
  )
}
